BIN = led_on
OBJS = head.o rcc.o systick.o gpio.o usart.o common.o main.o 

GCC = arm-none-eabi-
GFLAG = -mcpu=cortex-m3 -mthumb -Wall
CFLAG = -I./include/

$(BIN).bin: $(OBJS)
	$(GCC)ld -T$(BIN).lds $^ -o $(BIN)_elf
	$(GCC)objcopy -O binary -S $(BIN)_elf $(BIN).bin
	$(GCC)objdump -D -m arm $(BIN)_elf > $(BIN).dis

ftp: $(BIN).bin
	@chmod 0755 ./ftp.sh
	@./ftp.sh

%.o : %.s
	$(GCC)gcc $(GFLAG) $(CFLAG) -c -o $@ $<

%.o : %.S
	$(GCC)gcc $(GFLAG) $(CFLAG) -c -o $@ $<

%.o : %.c
	$(GCC)gcc $(GFLAG) $(CFLAG) -c -o $@ $<

clean:
	rm -f *.o *elf *.bin *.dis *~ *bak
